import { Controller, Post, Body, Ip, Request } from '@nestjs/common';
import { ArticleViewService } from './article-view.service';
import { CreateArticleViewDto } from './dto/create-article-view.dto';
import { Public } from 'src/auth/utils/public.metadata';
import { LogAction } from 'src/auth/utils/logging.metadata';

@Controller('article-view')
export class ArticleViewController {
  constructor(private readonly articleViewService: ArticleViewService) {}

  @Public()
  @Post()
  @LogAction('文章浏览')
  create(
    @Body() createArticleViewDto: CreateArticleViewDto,
    @Ip() ip: string,
    @Request() req: AuthRequest,
  ) {
    return this.articleViewService.create(
      createArticleViewDto,
      ip,
      req.user.userId,
    );
  }
}
